package yygh.common.execption;


import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import yygh.common.result.Result;

/**
 * 全局异常处理方式
 */

@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e){
        e.printStackTrace();
        return Result.fail();
    }

    @ExceptionHandler(HospitalException.class)
    @ResponseBody
    //自定义异常处理返回
    public  Result Hospital(HospitalException e){
        e.printStackTrace();
        return Result.fail();
    }

}
